package com.yonyou.pmclouds.safetypatrol.process;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.exception.BuziExCodeConst;
import com.yonyou.pmclouds.safetypatrol.entity.SafetypatrolVO;
import com.yonyou.pmclouds.safetypatrol.mapper.SafetypatrolMapper;

/**
 * @author 徐老板
 * @date 2020/4/17   10:14
 */

public class SafetypatrolDeleteCheckProcess implements SingleProcessor<SafetypatrolVO> {

    private SafetypatrolMapper safetypatrolMapper;

    public SafetypatrolDeleteCheckProcess(SafetypatrolMapper safetypatrolMapper) {
        this.safetypatrolMapper = safetypatrolMapper;
    }

    @Override
    public void process(SafetypatrolVO vo, SafetypatrolVO orig) throws BusinessException {
        //判断是否被引用
       Integer count= safetypatrolMapper.checkQupte(vo);
       if (count!=null && count>0){
           throw new BusinessException("该安全标准被引用 不能删除", BuziExCodeConst.CODE_NAME_BEEN_USED);
       }
    }
}
